<?php
/**
 * Class that modelize the Admin Menu
 */
class Application_Admin_Menu extends Zend_Navigation
{
    /**
     * @var array
     */
    private $_navigationParams = null;

    /**
     * @var Zend_Controller_Request_Abstract
     */
    private $_request;

    public function __construct($navigationParams = null, $pages = null, $request = null)
    {
        parent::__construct($pages);
        $this->_request = $request;
        $this->setNavigationParams($navigationParams);
        $this->addPage($this->_createChampionshipEntry());
        $this->addPage($this->_createTeamEntry());
        $this->addPage($this->_createPlayerEntry());
        $this->addPage($this->_createGoldBookEntry());
        $this->addPage($this->_createEventEntry());
        $this->addPage($this->_createWebnewsEntry());
        $this->addPage($this->_createAdminEntry());
    }

    /**
     * Set the params of navigation
     * @param array $navigationParams
     */
    public function setNavigationParams($navigationParams)
    {
        if (is_array($navigationParams)) {
            $this->_navigationParams = $navigationParams;
        } else {
            $this->_navigationParams = array();
        }
    }

    /**
     * Retrun all the navigation params
     * @return array
     */
    public function getNavigationParams()
    {
        return $this->_navigationParams;
    }

    /**
     * Return a specific navigation param
     * @param string $key
     * @return string
     */
    public function getNavigationParam($key)
    {
        if (!is_array($navigationP = $this->getNavigationParams())) {
            return null;
        }

        if (!isset($navigationP[$key])) {
            return null;
        }

        return $navigationP[$key];
    }

    /**
     * Create Championship link
     */
    public function _createChampionshipEntry()
    {
        $page = new Zend_Navigation_Page_Mvc(array(
            'label' => 'Championnats',
            'action' => 'championships',
            'controller' => 'admin',
            'id' => 'championship'
        ));
        return $page;
    }

    /**
     * Create Team link
     */
    public function _createTeamEntry()
    {
        $page = new Zend_Navigation_Page_Mvc(array(
            'label' => 'Equipes',
            'action' => 'teams',
            'controller' => 'admin',
            'id' => 'team'
        ));
        return $page;
    }

    /**
     * Create Player link
     */
    public function _createPlayerEntry()
    {
        $page = new Zend_Navigation_Page_Mvc(array(
            'label' => 'Joueurs',
            'action' => 'players',
            'controller' => 'admin',
            'id' => 'player'
        ));
        return $page;
    }

    /**
     * Create Gold book link
     */
    public function _createGoldBookEntry()
    {
        $page = new Zend_Navigation_Page_Mvc(array(
            'label' => "Livre d'or",
            'action' => 'goldbook',
            'controller' => 'admin',
            'id' => 'goldbook'
        ));
        return $page;
    }

    /**
     * Create Event link
     */
    public function _createEventEntry()
    {
        $page = new Zend_Navigation_Page_Mvc(array(
            'label' => 'Evènements',
            'action' => 'event',
            'controller' => 'admin',
            'id' => 'event'
        ));
        return $page;
    }

    /**
     * Create Webnews link
     */
    public function _createWebnewsEntry()
    {
        $page = new Zend_Navigation_Page_Mvc(array(
            'label' => 'Webnews',
            'action' => 'webnews',
            'controller' => 'admin',
            'id' => 'webnews'
        ));
        return $page;
    }

    /**
     * Create Admin link
     */
    public function _createAdminEntry()
    {
        $page = new Zend_Navigation_Page_Mvc(array(
            'label' => 'Administrateurs',
            'action' => 'admins',
            'controller' => 'admin',
            'id' => 'admin'
        ));
        return $page;
    }
}